//
//  SystemTableViewCell.m
//  project
//
//  Created by 黄建华 on 2018/8/15.
//  Copyright © 2018年 黄建华. All rights reserved.
//

#import "SystemTableViewCell.h"

@implementation SystemTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    
    return self;
}

- (void)createView {
    _imageV = [[UIImageView alloc] init];
    [self addSubview:_imageV];
    
    _nickLabel = [[UILabel alloc] init];
    [self addSubview:_nickLabel];
    
    _infoLabel = [[UILabel alloc] init];
    [self addSubview:_infoLabel];
    
    _line = [[UIView alloc] init];
    [self addSubview:_line];
}

- (void)updateCellWithModel:(FriednInviterModel *)model {
    _imageV.frame               = SNFRAME(20, 10, 40, 40);
    _imageV.frame               = SNFRAME(20, 10, 40, 40);
    _imageV.layer.masksToBounds = YES;
    _imageV.layer.cornerRadius  = _imageV.width /2.0;
    
    _nickLabel.frame     = SNFRAME(_imageV.right + 15, 5, 220, 25);
    _nickLabel.font      = SNFONT(15.0);
    _nickLabel.textColor = SNCOLORBLACK;
    _nickLabel.adjustsFontSizeToFitWidth = YES;
    _nickLabel.minimumScaleFactor = 0.5;
    NSString *typeString = @"";
    if (model.type.intValue == 1) {
        typeString    = SN_Text(@"赞了你一下");
        _imageV.image = [UIImage image:@"点赞"];
    } else if (model.type.intValue == 2) {
        typeString    = SN_Text(@"鼓励你多运动");
        _imageV.image = [UIImage image:@"鼓励"];
    } else if (model.type.intValue == 3) {
    [_imageV sd_setImageWithURL:[NSURL URLWithString:model.imagePathUrlString] placeholderImage:[UIImage imageNamed:@"loginhead"]];
    }
    _nickLabel.text = [NSString stringWithFormat:@"%@ %@", model.showNickName, typeString];
    
    _infoLabel.frame     = SNFRAME(0, 0, 150, 20);
    _infoLabel.text      = model.send_time;
    _infoLabel.textColor = SNCOLORGRAY;
    _infoLabel.frame     = SNFRAME(_imageV.right + 15, _nickLabel.bottom + 1, 200, 20);
    _infoLabel.font      = SNFONT(12.0);
    _infoLabel.adjustsFontSizeToFitWidth = YES;
    _infoLabel.minimumScaleFactor = 0.5;
    _line.frame = SNFRAME(0, 59, screenWidth, 1);
}

@end
